// pages/mine/patrolRecord/patrolRecord.js
import { lgRequest } from '../../../utils/ajax'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sysInfo: getApp().globalData.sysInfo,
    isIphoneX: getApp().globalData.isIphoneX,
    statusBarHeight: getApp().globalData.statusBarHeight,
    titleBarHeight: getApp().globalData.titleBarHeight,
    userId:'',
    searchList:[],
    rightImgIcon:'https://www.mingchuliangzao.com.cn:8632/profile/upload/2022/06/24/a14ca79c67896c3fba0b575e86f3fe34.png',
    delectImg:'https://www.mingchuliangzao.com.cn:8632/profile/upload/2022/07/19/713a49f43240fae4d44090d92d7f9cf6.png',
    patrolPop:false,
    selectItem:{},
    userInfo:wx.getStorageSync('userInfo'),
  },
  goBack(){
    wx.navigateBack({
      delta: 1
    })
  },
  getList(){
    let params = {
      createBy:this.data.userInfo.userId
    }
    lgRequest('patrolRecordList', params, {
      errAlert: false,
      doSuccess: r => {
        if (r.code == 200) {
          console.log(r,'巡查记录');
          r.data.forEach(item=>{
            item.createTime = item.createTime?item.createTime.split(/\s+/):[]
          })
          this.setData({
            searchList:r.data
          })
        } else {
          wx.showToast({
            title: r.msg,
            icon: 'none'
          })
        }
      },
      doComplete: r => {
      }
    })
  },
  //查看详情
  searchDetail(e){
    let item = e.currentTarget.dataset.item||{}
    if(item.pic){
      item.pic = item.pic.split(',')
    }
    this.setData({
      patrolPop:!this.data.patrolPop,
      selectItem:item
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      userId: options.userId
    })
    this.getList()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})